using System;
using System.Collections.Generic;

namespace Subsync.Core.Subversion
{
	/// <summary>
	/// Author: Steven Goh Jian Wen
	/// </summary>
	public class Tools
	{		
		public static void SetupLibrary ()
		{
			// for DAV (over http and https)
			org.tmatesoft.svn.core.@internal.io.dav.DAVRepositoryFactory.setup ();
			// for SVN (over svn and svn+ssh)
			org.tmatesoft.svn.core.@internal.io.svn.SVNRepositoryFactoryImpl.setup ();
			// Working copy storage (default is file system).
			org.tmatesoft.svn.core.@internal.io.fs.FSRepositoryFactory.setup ();
		}
		
		public static Dictionary<long, Dictionary<string, string>> GetRevisionHistory (string path)
		{
			Dictionary<long, Dictionary<string, string>> ret = new Dictionary<long, Dictionary<string, string>> ();
			long head_revision_no;

			SVNStatus stat = new SVNStatus (path);
			stat.Execute ();
			head_revision_no = stat.statusInfo.workingRevision;
			
            for (int i = 0; i <= head_revision_no; i++)
            {
                SVNInfo rev_info = new SVNInfo(path, i.ToString());
                rev_info.Execute();

                Dictionary<string, string> tmp = new Dictionary<string, string>();
                tmp["date"] = rev_info.revInfo.committedDate.ToString();
                ret[i] = tmp;
            }
			return ret;
		}
	}
}
